{extend name="public/header" /}
{block name="body"}
<link rel="stylesheet" href="/admin/css/other.css" type="text/css">
<body>
{include file="public/common" /}
<fieldset class="layui-elem-field site-demo-button" style="padding:10px;">
    <div class="layui-row">
		<!--  -->
		<form id="form1" class="layui-form layui-form-pane" action="{:url('')}">
			<input type="hidden" name="id" value="{$info.id}">
			<section class="panel panel-padding">
				<div class="layui-form-item">
					<label class="layui-form-label">账号</label>
					<div class="layui-input-inline">
						<input type="text" name="username" value="{$info.username}" {if !empty($info)}disabled{/if} class="layui-input">
					</div>
				</div>
				<div class="layui-upload" id="pic_img">
					<span class="fileinput-button">
						<span class="layui-btn">头像</span>
						<input type="file" id="pic" class="layui-btn file" accept="image/gif,image/jpg,image/jpeg,image/x-png"/>
					</span>
					<div class="layui-upload-list">
						<a href="{$info.thumb}" target="_blank"><img class="layui-upload-img" {if !empty($info.thumb)}src="{$info.thumb}"{/if} ></a>
						<input name="thumb" type="hidden" value="{$info.thumb|default=''}"/>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">昵称</label>
					<div class="layui-input-inline">
						<input type="text" name="nickname" value="{$info.nickname|default=''}" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-inline">
						<input type="text" name="name" value="{$info.name|default=''}" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">手机号</label>
					<div class="layui-input-inline">
						<input type="text" name="phone" value="{$info.phone|default=''}" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-inline">
						<input type="radio" name="status" {eq name="info.status" value="1"}checked{/eq} title="正常" value="1" checked />
						<input type="radio" name="status" {eq name="info.status" value="2"}checked{/eq} title="禁用" value="2" />
					</div>
				</div>
				
				<div class="layui-input-block">
					<input type="hidden" name="id" type="hidden" value="{$info.id|default=''}">
					<button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</section>
		</form>
		<!--  -->
    </div>
</fieldset>
</body>
{/block}
{block name="script"}
<script>
layui.use(['jquery','form','laydate','upload','element'], function(){
	var $ = layui.jquery
	,laydate = layui.laydate
	,upload = layui.upload
	,element = layui.element
	,form = layui.form;

	//单图上传 缩略图
	$('#pic_img .file').change(function(event) {
		layer.msg('正在上传中',{icon:6,time:10000});
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		$.ajax({
			url:'{:url("upload/upFile")}',
			type:'POST',
			data:formData,
			cache: false,
			contentType: false,    //不可缺
			processData: false,    //不可缺
			success:function(res){
				console.log(res);
				//如果上传失败
				if(res.code != 1){
					return layer.msg('上传失败');
				}
				//上传成功
				layer.close(layer.index);
				layer.msg('上传成功',{icon:1,time:2000});
				var data = res.data;
				$('#pic_img .layui-upload-list a').attr('href', data.picurl);
				$('#pic_img .layui-upload-list img').attr('src', data.picurl);
				$('#pic_img .layui-upload-list input').val(data.picurl);
			},
			error: function(res){
				console.log(res);
			}
		});
	});

	form.render();
});
</script>
{/block}